package com.gw.controller;

import com.gw.mapper.EssayMapper;
import com.gw.pojo.entity.HotEssay;
import com.gw.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hot")
@Slf4j
public class EssayController {

    @Autowired
    private EssayMapper essayMapper;

    /**
     * 获取每日热榜文章
     * @return
     */
    @GetMapping("/getEssay")
    public Result<List<HotEssay>> getHot(){
        log.info("获取csdn热榜文章...");
        List<HotEssay> list = essayMapper.getEssay();
        return Result.success(list);
    }
}
